#include "StdAfx.h"
#include "strsafe.h"
#include "dispositifD3D11.h"
#include "Texture.h"
#include "resource.h"
#include "util.h"

using namespace UtilitairesDX;

namespace PM3D
{
	CTexture::~CTexture(void)
	{
		DXRelacher(pTexture);
	}

	CTexture::CTexture(const wchar_t* filename_in, CDispositifD3D11* pDispositif)
	{
		pTexture = 0;
		ID3D11Device* pDevice = pDispositif->GetD3DDevice();

		StringCchCopy(filename, sizeof(filename), filename_in);

		// Charger la texture en ressource
		DXEssayer(D3DX11CreateShaderResourceViewFromFile(pDevice, filename, NULL, NULL, &pTexture, NULL), DXE_FICHIERTEXTUREINTROUVABLE);
	}

	const wchar_t* CTexture::GetFilename()
	{
		return filename;
	}

	ID3D11ShaderResourceView* CTexture::GetD3DTexture()
	{
		return pTexture;
	}
}